//
//  CZVisitorTableController.swift
//  weiBo
//
//  Created by apple on 16/5/11.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZVisitorTableController: UITableViewController {
    //设置用户登录标识
    var userLogin = CZUserCountViewModel.sharedUserAccount.isLogin
    var visitorView: CZVisitorView?
    override func loadView() {
        if userLogin
        {
            super.loadView()
        }else
        {
            visitorView = CZVisitorView()
            visitorView?.callBackClosure = { [weak self] in
//                print("哈哈")
//                print(self)
                
                //跳转界面
                self?.requestOAuthLogin()
            }
            view = visitorView
            // 创建按钮
            setUpNavUi()
        }
        
    }
    private func setUpNavUi()
    {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fontSize: 15, target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fontSize: 15, target: self, action: "loadAction")
    
    }
    
    @objc private func registerAction(){
        requestOAuthLogin()
    }
    
    @objc private func loadAction(){
        requestOAuthLogin()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    
    }
    //跳转登录界面
    private func requestOAuthLogin(){
        let oauthVC = CZOAuthViewController()
        let nav = UINavigationController(rootViewController: oauthVC)
        presentViewController(nav, animated: true, completion: nil)
    
    }


}
